const URL_TITLE = 'http://127.0.0.1:3000/mock/11'
export const get = (url, params = {}) => {
    let URL = URL_TITLE + url
    let str = '';
    for (let key in params) {
        if (!str) {
            str += '?' + key + "=" + params[key]
        } else {
            str += '&' + key + "=" + params[key]
        }
    }
    return fetch(URL + str).then(res => res.json())
}
export const post = (url, params = {}) => {
    let URL = URL_TITLE + url
    console.log(params);
    return fetch(URL, {
        method: 'POST',
        headers: {
            "Content-Type": "application/json",
        },
        // body: JSON.stringify(params)
    }).then(res => res.json()).then(res => {
        const { data } = res || {};
        return data
    })
}
export default {
    get,
    post
}